package sandbox
import scala.collection.immutable.SortedMap
import scala.collection.immutable.ListMap

object testzemaps {

  def main(args: Array[String]): Unit = {}

}

class StringOrder extends Ordering[String] {
	override def compare(s1: String, s2: String) = s1.compare(s2)
}
class MyParameter() {}


class ZeParameters(val pairs:List[(String,MyParameter)] = Nil) extends ListMap[String,MyParameter] {
	/**** Minimal Map stuff begin ****/
	lazy val keyLookup = Map() ++ pairs
	override def get(key: String): Option[MyParameter] = keyLookup.get(key)
	override def iterator: Iterator[(String, MyParameter)] = pairs.reverseIterator
	override def + [B1 >: MyParameter](kv: (String, B1)) = {
		val (key:String, value:MyParameter) = kv
		new ZeParameters((key,value) :: pairs)
	}
	override def -(key: String): ZeParameters  = new ZeParameters(pairs.filterNot(_._1 == key))
	/**** Minimal map stuff end ****/
	/**** Minimal SortedMap stuff begin ****
	def rangeImpl (from: Option[String], until: Option[String]): ZeParameters = {
		val out = pairs.filter((p: (String, MyParameter)) => {
			var compareFrom = 0
			from match {
				case Some(s) => compareFrom = p._1.compare(s)
				case _ =>
			}
			var compareUntil = 0
			until match {
				case Some(s) => compareUntil = p._1.compare(s)
				case _ =>
			}
			compareFrom>=0 && compareUntil<=0
		})
		new ZeParameters(out)
	}
	
	def ordering: Ordering[String] = new StringOrder
	**** Minimal SortedMap stuff end ****/
}
